package com.wy.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wy.dao.User;
import com.wy.dao.UserParam;
import com.wy.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 33117
 * @version 1.0
 * @data 2025/3/1 16:12
 */
@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public List<User> list(UserParam userParam) {
        List<User> list = userMapper.listt(userParam);
        return list;
    }

    public List<User> listpage(String name) {
        LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(name)){
            userLambdaQueryWrapper.like(User::getName,name);
        }
        List<User> list = userMapper.selectList(userLambdaQueryWrapper);
        return list;
    }

    public List<User> findGetName(LocalDateTime time) {
        LambdaQueryWrapper<User> userQueryWrapper = new LambdaQueryWrapper<>();
        if (time != null){
            userQueryWrapper.gt(User::getCreateTime,time);
        }
        List<User> list = userMapper.selectList(userQueryWrapper);
        return list;
    }
}
